
/*Includes ----------------------------------------------*/
#include "hal/inc/b_hal.h"

/**
 * \addtogroup B_HAL
 * \{
 */

/**
 * \addtogroup PWM
 * \{
 */

/**
 * \defgroup PWM_Private_Variables
 * \{
 */

/**
 * \}
 */

/**
 * \addtogroup PWM_Private_Functions
 * \{
 */

/**
 * \}
 */

/**
 * \addtogroup PWM_Exported_Functions
 * \{
 */
#if defined(__WEAKDEF)
__WEAKDEF int bMcuPwmInit(bPwmConfig_t *config)
{
    return -1;
}

__WEAKDEF int bMcuPwmDeInit(bPwmChannel_t channel)
{
    return -1;
}

__WEAKDEF int bMcuPwmStart(bPwmChannel_t channel)
{
    return -1;
}

__WEAKDEF int bMcuPwmStop(bPwmChannel_t channel)
{
    return -1;
}

__WEAKDEF int bMcuPwmSetDuty(bPwmChannel_t channel, uint8_t duty)
{
    return -1;
}

__WEAKDEF int bMcuPwmSetFrequency(bPwmChannel_t channel, uint32_t frequency)
{
    return -1;
}
#endif
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------

int bHalPwmInit(bPwmConfig_t *config)
{
    if(config == NULL) return -1;
    if(config->duty > 100) return -1;
    return bMcuPwmInit(config);
}

int bHalPwmDeInit(bPwmChannel_t channel)
{
    if(channel > PWM_CHANNEL_4) return -1;
    return bMcuPwmDeInit(channel);
}

int bHalPwmStart(bPwmChannel_t channel)
{
    if(channel > PWM_CHANNEL_4) return -1;
    return bMcuPwmStart(channel);
}

int bHalPwmStop(bPwmChannel_t channel)
{
    if(channel > PWM_CHANNEL_4) return -1;
    return bMcuPwmStop(channel);
}

int bHalPwmSetDuty(bPwmChannel_t channel, uint8_t duty)
{
    if(channel > PWM_CHANNEL_4) return -1;
    if(duty > 100) return -1;
    return bMcuPwmSetDuty(channel, duty);
}

int bHalPwmSetFrequency(bPwmChannel_t channel, uint32_t frequency)
{
    if(channel > PWM_CHANNEL_4) return -1;
    if(frequency == 0) return -1;
    return bMcuPwmSetFrequency(channel, frequency);
}

/**
 * \}
 */

/**
 * \}
 */

/**
 * \}
 */

/************************ Copyright (c) 2024 Bean *****END OF FILE****/ 